package com.wzy.level.user.userServlet;

import com.wzy.Jdbc封装.pojo.News_detail;
import com.wzy.Jdbc封装.pojo.News_user;
import com.wzy.level.detail.detailService.detailService;
import com.wzy.level.detail.detailServiceImpl.detailServiceImpl;
import com.wzy.level.detail.detailServlet.detail;
import com.wzy.level.user.userService.userService;
import com.wzy.level.user.userServiceImpl.userServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/user_delete")
public class deleteServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int id = Integer.parseInt(req.getParameter("id"));
        News_user user1 = new News_user();
        user1.setId(id);
        userService user = new userServiceImpl();
        int i = user.deleteById(user1);
//        req.setAttribute("rows",i);
        if(i>0){
//            req.getRequestDispatcher("/pageManage?cate=2").forward(req,resp);
            resp.sendRedirect("http://localhost:8080/pageManage?cate=2");
        }else {
            System.out.println("删除失败");
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        super.doPost(req, resp);
    }

//    //处理请求和生成响应
//    @Override
//    public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
//        super.service(req, res);
//        System.out.println("处理请求，分发任务。。。。。。");
//    }
//
//    //初始化方法，仅仅只会执行一次
//    @Override
//    public void init(ServletConfig config) throws ServletException {
//        super.init(config);
//        System.out.println("初始化");
//    }
//
//    //服务器停止，程序中Servlet对象不在使用的时候调用，只执行一次
//    @Override
//    public void destroy() {
//        super.destroy();
//        System.out.println("销毁");
//    }
}
